package com.ustudy.entity.cms;

import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.ustudy.core.dao.support.entity.LongIdEntity;
import org.ustudy.core.dao.support.entity.StringIdEntity;

import com.ustudy.entity.commons.PagesTemplate;

/**
 * 新闻板块
 * @author Hector
 *
 */
@SuppressWarnings("serial")
@Entity(name="PageBlock")
@Table(name="CMS_PAGE_BLOCK")
public class PageBlock extends StringIdEntity {
	
	private String code;
	
	private String name;
	
	@Column
	@Lob
	@Basic(fetch=FetchType.LAZY)
	private String body;
	
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.LAZY)
	@JoinColumn(name="TPL_ID")
	private PagesTemplate pagesTemplate;
	
	@Enumerated
	@Column(name="PB_TYPE")
	private BlockType type=BlockType.SYS;
	
	
	public static enum BlockType{
		SYS("系统内置"),DB("数据库"),FS("外部文件");
		private final String label;
		private BlockType(String label){
			this.label=label;
		}
		public String getLabel() {
			return label;
		}
	}
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public BlockType getType() {
		return type;
	}

	public void setType(BlockType type) {
		this.type = type;
	}

	public PagesTemplate getPagesTemplate() {
		return pagesTemplate;
	}

	public void setPagesTemplate(PagesTemplate pagesTemplate) {
		this.pagesTemplate = pagesTemplate;
	}
}
